import isObject from '../object/isObject'

const nativeKeys = Object.keys
const hasOwnProperty = Object.prototype.hasOwnProperty

function keys(obj) {
  if (!isObject(obj)) return []
  if (nativeKeys) return nativeKeys(obj)

  const result = []
  for (let key in obj) {
    if (hasOwnProperty.call(obj, key)) {
      result.push(key)
    }
  }

  return result
}

export default keys
